﻿using System;
using System.Runtime.InteropServices;
using Felbot.Interaction;
using Felbot.Interface.Users;
using Felbot.Profiles;

namespace Felbot.Scripting {
    /// <summary>Provides data for the ScriptControl.ScriptControl events.</summary>
    [Serializable]
    [ComVisible(true)]
    public class ScriptEventArgs : EventArgs {
        private ScriptData m_Data;

        /// <summary>
        /// Initializes a new instance of the ScriptControl.ScriptEventArgs class with the parameters provided.
        /// </summary>
        /// <param name="args">The parameters to pass to the script.</param>
        public ScriptEventArgs(ScriptData data)
            : base() {
            m_Data = data;
        }

        /// <summary>
        /// Gets the data.
        /// </summary>
        public ScriptData Data {
            get {
                return m_Data;
            }
        }
    }

    public class ScriptData {
        private object[] m_Parameters;
        private CommandSource m_Source;

        public object[] Parameters {
            get {
                return m_Parameters;
            }
        }

        public CommandSource Source {
            get {
                return m_Source;
            }
        }

        public string Username {
            get {
                return m_Source.User.RealUsername;
            }
        }

        public ChannelUser ChannelUserItem {
            get {
                return m_Source.User;
            }
        }

        public Profile Profile {
            get {
                return m_Source.Profile;
            }
        }

        /// <summary>
        /// Creates a new script data object.
        /// </summary>
        /// <param name="source">The command source object.</param>
        /// <param name="parameters">The parameters object.</param>
        public ScriptData(CommandSource source, object[] parameters) {
            m_Source = source;
            m_Parameters = parameters;
        }
    }
}
